package com.hr.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hr.entity.ConfigFileFirstKind;
import com.hr.mapper.ConfigFileFirstKindMapper;
import com.hr.service.ConfigFileFirstKindService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 一级机构设置 的业务
 */
@Service
public class ConfigFileFirstKindServiceImpl implements ConfigFileFirstKindService {
    //自动装配
    @Autowired
    private ConfigFileFirstKindMapper configFileFirstKindMapper;

    /**
     * 查询一级机构
     * @return
     */
    @Override
    public List<ConfigFileFirstKind> queryList() {
        return configFileFirstKindMapper.selectList(new QueryWrapper<ConfigFileFirstKind>());
    }

    /**
     * 保存/修改
     * @param configFileFirstKind
     * @return
     */
    @Override
    public boolean save(ConfigFileFirstKind configFileFirstKind) {
        int row=0;
        if(configFileFirstKind.getFfkid()==null){
            row= configFileFirstKindMapper.insert(configFileFirstKind);
        }else{
            row= configFileFirstKindMapper.updateById(configFileFirstKind);
        }
        return  row>0;
    }

    /**
     * 删除
     * @param ffkid
     * @return
     */
    @Override
    public boolean del(Integer ffkid) {
        int i = configFileFirstKindMapper.deleteById(ffkid);
        return i>0;
    }

    /**
     *根据ffkid查询单个ConfigFileFirstKind对象
     * @param ffkid
     * @return
     */
    @Override
    public ConfigFileFirstKind queryById(Integer ffkid) {
        ConfigFileFirstKind configFileFirstKind = configFileFirstKindMapper.selectById(ffkid);
        return configFileFirstKind;
    }


}
